<?php

namespace App\Admin\Controllers\Export;

use App\Admin\Exports\CategoryExport;
use App\Admin\Exports\ClickLearnExport;
use App\Admin\Exports\SentenceExport;
use App\Admin\Exports\VirtualExport;
use App\Admin\Exports\LearnWordExport;
use App\Admin\Exports\VocabularyExport;
use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;
use App\Admin\Exports\CategoryModuleExport;
use App\Admin\Exports\TextbookAudioExport;
class ExcelExportController extends Controller
{
    public function dataExport()
    {
        $url = request()->input('uri');

        switch ($url) {
            case '/skuCategoryExport':
                return Excel::download(new CategoryExport(), '书籍_'.time().'.xlsx');
            case '/CategoryModule':
                return Excel::download(new CategoryModuleExport(), '书籍模块_'.time().'.xlsx');
            case '/ClickLearnExport':
                return Excel::download(new ClickLearnExport(), '资源内容_'.time().'.xlsx');
            case '/SentenceExport':
                return Excel::download(new SentenceExport(), '常用表达法_'.time().'.xlsx');
            case '/TextbookAudioExport':
                return Excel::download(new TextbookAudioExport(), '歌曲歌谣_'.time().'.xlsx');
            case '/VirtualExport':
                return Excel::download(new VirtualExport(), '情境学习_'.time().'.xlsx');
            case '/LearnWordExport':
                return Excel::download(new LearnWordExport(), '背单词_'.time().'.xlsx');
            case '/VocabularyExport':
                return Excel::download(new VocabularyExport(), '单元词汇表_'.time().'.xlsx');

            default:
                abort(404, '未找到对应的导出类型');
        }
    }
}
